require "View/Expedition/Manager/ExpeditionMapMgr"

---@class UIExpeditionStageView : UIBase
UIExpeditionStageView = UIBase.New(PanelResNames.UIExpeditionStageView)
local t = UIExpeditionStageView
function t.Init(_showPrefabIn)
    t._showPrefabIn = _showPrefabIn
    UIBase.Init(t)
end

function t:OnCreate()
    self.mapIcon = self:GetChild("mapIcon")
    self.ctrlMap = self:GetController("map")
    self.ctrlMap2 = self:GetChild("WorldMap"):GetController("map")
    self.btnTips = self:GetChild("Tips")
    self.btnClose = self:GetChild("Backbutton")
    self.btnRush = self:GetChild("Btn_Rush")
    self.ctrlSweepType = self.btnRush:GetController("type")
    --self.btnReset = self:GetChild("ResetButton")
    self.btnChallenge = self:GetChild("ChallengeButton")
    self.ctrlReset = self:GetController("reset")
    --self.resetTitle = self:GetChild("Title",self.btnReset)
    self.resetTime = self:GetChild("ResetTimeRemain")
    self.player = self:GetChild("player")
    self.Text_Num1 = self:GetChild("Com_Privilege"):GetChild("Text_Num1")
    self.Text_Num2 = self:GetChild("Com_Privilege"):GetChild("Text_Num2")
    self.privilegeController = self:GetController("Privilege")
    self.playerIcon = self:GetChild("icon/icon",self.player)
    self.ticketIcon = self:GetChild("Com_Res")
    self.ticketJumpBtn = self.ticketIcon:GetChild("btnJump")
    self.ticketJumpCtrl = self:GetController("showSource")
    self.ticketAddCtrl = self.ticketIcon:GetController("add")
    self.ticketCount = self.ticketIcon:GetChild("title")
    self.ctrlMarkLoading = self:GetController("mark")
    self.Graph_UI_ruchang_xyyz_1 = self:GetChild("Graph_UI_ruchang_xyyz_1");
    self.btnTicket = self:GetChild("TicketButton")
    self.btnGiveUp = self:GetChild("Btn_Giveup")

    self.nextRecoverTime = self:GetChild("Text_NextRecoverTime")
    self.fullRecoverTime = self:GetChild("Text_FullRecoverTime")
    self.btnStamina = self:GetChild("Btn_ Stamina")
    self.staminaCount = self.btnStamina:GetChild("title")
    self.btnAddStrength = self:GetChild("Btn_Add")

    self._xyyzPlayTime = 1000  -- 旋云远征入场动画持续时间（毫秒）
    self.levelBtnList = {}
    self.delayLoad = false
    self.effDrawWrapper = GoWrapper.New();
    local index = 1
    for k,v in pairs(logicMgr.ExpeditionMgr.stageList) do
        local go = self:GetChild("Level"..index)
        if go == nil then break end
        local icon = go:GetChild("icon")
        local type = go:GetController("type")
        local head = go:GetController("head")
        self:RegisterOnClick(go,self.ClickLevelBtn,self,k)
        self.levelBtnList[k]= {go = go,icon = icon,ctrlType = type,ctrlHead = head}
        index = index + 1
    end
    ---@type GController[]
    self.pathList = {}
    for i = 1,11 do
        local go = self:GetChild("Path"..i)
        local ctrl = go:GetController("reach")
        table.insert(self.pathList,ctrl)
    end
    self.btnBless = self:GetChild("BlessButton")
    self.btnHolyStone = self:GetChild("HolyStoneButton")
    self.btnHero = self:GetChild("HeroButton")
    self.btnShop = self:GetChild("LongJourneyShopButton")

    self:RegisterOnClick(self.btnClose,self.ClickClose)
    --self:RegisterOnClick(self.btnReset,self.ClickReset)
    self:RegisterOnClick(self.btnTips,self.ClickInfo)
    self:RegisterOnClick(self.btnBless,self.ClickBless)
    self:RegisterOnClick(self.btnTicket,self.ClickUseTicket)
    self:RegisterOnClick(self.btnHolyStone,self.ClickHolyStone)
    self:RegisterOnClick(self.btnHero,self.ClickHero)
    self:RegisterOnClick(self.btnShop,self.ClickShop)
    self:RegisterOnClick(self.btnChallenge,self.ClickChallenge)
    self:RegisterOnClick(self.btnRush,self.ClickSweep)
    self:RegisterOnClick(self.btnGiveUp,self.ClickGiveUp)
    self:RegisterOnClick(self.btnAddStrength,self.ShowAddStrength)
    --self:RegisterEvent(Config.EventType.ExpeditionGetRewardSuc,self.ExpeditionGetRewardSucMsg)
    self:RegisterEvent(Config.EventType.ExpeditionDataRefresh,self.ExpeditionDataRefreshMsg)
    self:RegisterEvent(Config.EventType.ExpeditionStartLoading,self.ExpeditionStartLoadingMsg)
    self:RegisterEvent(Config.EventType.Fresh_ExpeditionStrength,self.FreshExpeditionStrength)
    UIRedDots.addViewListen(PanelNames.UIExpeditionStageView, "UIExpeditionStageView_btn_Ticket", self.btnTicket, Config.RedDotsType.ExpeditionSweep);
    self:ExpeditionStartLoadingMsg(true)
    self.isWaitingMsg = false
    if logicMgr.ExpeditionMgr.showExpeditionImmediate then
        logicMgr.ExpeditionMgr.showExpeditionImmediate = false
        self.isWaitingMsg = true
        FightManager.leaveRoundBattle(false)
        ExpeditionHandler.closeAllUI()
        --local time = logicMgr.ExpeditionMgr.endTime-HelperFunc.GetServerTime()
        --if time > 0 then
            self:ReqSynExpedition()
            self:TimeCall(self.ReqSynExpedition,2000,-1)
        --end
        self.delayLoad = true
    end
    --Util.SetPlayerPrefs(HeroManager.GetRoleId().."expeditionOpen","1")
end

function t:OnEnable()
    UIHeadMenu.isNeedShowMask(true);
    if self._showPrefabIn then
        resMgr:LoadModelPrefab("UIEff/UI_ruchang_xyyz_in", function(prefab)
            if self.effFireObj ~= nil then
                destroyImmediate(self.effFireObj);
                self.effFireObj = nil;
            end
            self.effFireObj = newObject(prefab)
            self.effDrawWrapper:SetWrapTarget(self.effFireObj,false)
            Util.Lua_SetLocalRotationXYZ(self.effFireObj.transform, 0, 0, 0);
            self.Graph_UI_ruchang_xyyz_1:SetNativeObject(self.effDrawWrapper)
        end)
    end
    self:RemoveShowMaskTimer();
    self.showMaskTimer = utimer.timeCall(function ()
        UIHeadMenu.isNeedShowMask();
        self:RemoveShowMaskTimer();
        if self.effFireObj ~= nil then
            destroyImmediate(self.effFireObj);
            self.effFireObj = nil;
        end
    end, self._xyyzPlayTime, 1);

    AudioManager.SetSwitch("battle_steps", "arr")
    FightManager.SetBGMSwitchByBattleType(EnumConst.FightTypeConst.Expedition)
    AudioManager.SetSwitch("Battle_SwitchGroup","expedition")
    self:Refresh()
    self:RemoveTimeCall(self.UpdateTime)
    self:TimeCall(self.UpdateTime,1000,-1)
    self:UpdateTime();

    if not self.delayLoad then
        ExpeditionMapMgr.LoadScene()
        if logicMgr.ExpeditionMgr.showBuffId[1] > 0 then
            self:TimeCall(self.ShowSelectBuffView,110)
        end
    end

    --self:CheckBossReward()
    self:RefreshRecoverTime()
    self:RefreshStaminaCount()
end
function t:RemoveShowMaskTimer()
    if self.showMaskTimer ~= nil then
        UIHeadMenu.isNeedShowMask();
        utimer.remove(self.showMaskTimer)
        self.showMaskTimer = nil
    end
end
function t:OnDisable()
    self:RemoveTimeCall(self.UpdateTime)
    self:RemoveShowMaskTimer()
end
function t:OnDestroy()
    self:RemoveTimeCall(self.UpdateTime)
    self:RemoveShowMaskTimer()
    UIRedDots.removeViewEvent(PanelNames.UIExpeditionStageView)
    ExpeditionMapMgr.DestroyScene()
    if self.effFireObj ~= nil then
        destroy(self.effFireObj);
        self.effFireObj = nil;
    end
    if self.effDrawWrapper then
        self.effDrawWrapper:Dispose();
        self.effDrawWrapper = nil;
    end
    if self.nextRefreshTimer then
        utimer.remove(self.nextRefreshTimer)
        self.nextRefreshTimer = nil
    end
    if self.fullTimer then
        utimer.remove(self.fullTimer)
        self.fullTimer = nil
    end
end
--[[function t:CheckBossReward()
    local stageId = ExpeditionMgr.GetCurStageId()
    local cfg = logicMgr.ExpeditionMgr.GetCurStageCfg(stageId)
    if cfg and cfg.f_ExpeditionType == 3 then
        local state = ExpeditionMgr.GetStageFullState(stageId)
        if state == ExpeditionMgr.StageState.reward then
            ExpeditionHandler.ReqGetAward(stageId)
        end
    end

end]]
function t:FreshExpeditionStrength()
    self:RefreshRecoverTime()
    self:RefreshStaminaCount()
end
function t:RefreshRecoverTime()
    if logicMgr.ExpeditionMgr.GetNextRefreshEnergyTime() > 0 then
        local countTime = logicMgr.ExpeditionMgr.GetNextRefreshEnergyTime() - HelperFunc.GetServerTime()
        if countTime > 0 then
            if self.nextRefreshTimer then
                utimer.remove(self.nextRefreshTimer)
                self.nextRefreshTimer = nil
            end
            self.nextRefreshTimer =  utimer.timeCall(function()
                countTime = countTime - 1
                if countTime <= 0 then
                    countTime = 0
                    utimer.remove(self.nextRefreshTimer)
                    self.nextRefreshTimer = nil
                    logicMgr.ExpeditionMgr.RecoverStrength()
                    self:RefreshStaminaCount()
                    self:RefreshRecoverTime()
                end
                self.nextRecoverTime.text = HelperFunc.GetTimeStr(countTime)
            end, 1000, -1)
        end
    else
        if self.nextRefreshTimer then
            utimer.remove(self.nextRefreshTimer)
            self.nextRefreshTimer = nil
        end
        self.nextRecoverTime.text = HelperFunc.GetTimeStr(0)
    end

    if logicMgr.ExpeditionMgr.GetEnergyFullTime() > 0 then
        local countTime = logicMgr.ExpeditionMgr.GetEnergyFullTime() - HelperFunc.GetServerTime()
        if countTime > 0 then
            if self.fullTimer then
                utimer.remove(self.fullTimer)
                self.fullTimer = nil
            end
            self.fullTimer =  utimer.timeCall(function()
                countTime = countTime - 1
                if countTime <= 0 then
                    countTime = 0
                    utimer.remove(self.fullTimer)
                    self.fullTimer = nil
                end
                self.fullRecoverTime.text = HelperFunc.GetTimeStr(countTime)
            end, 1000, -1)
        end
    else
        if self.fullTimer then
            utimer.remove(self.fullTimer)
            self.fullTimer = nil
        end
        self.fullRecoverTime.text = HelperFunc.GetTimeStr(0)
    end
end

function t:RefreshStaminaCount()
    local curStrength = logicMgr.ExpeditionMgr.strength
    local maxStrength = logicMgr.ExpeditionMgr.GetFullEnergy()
    self.staminaCount.text = curStrength.."/"..maxStrength
end

function t:ReqSynExpedition()
    ExpeditionHandler.ReqSynExpedition(true)
end
function t:Refresh()
    local useSkinId = logicMgr.SkinManager.getHeroSkinId(HeroManager.GetRoleHeadID())
    self.playerIcon.url = SkinManager.GetHeroIconBySkinId(useSkinId)--EnumConst.AtlasPath.ICONAtlas ..HeroManager.GetRoleIcon(useSkinId)
    self:RefreshMapIcon()
    self:RefreshReset()
    self:RefreshLevelBtn()
    self:RefreshTicket()
    if logicMgr.ExpeditionMgr.IsCompleteAllStage() then
        self.ctrlReset.selectedIndex = 1
        self.player.visible = false
        logicMgr.ExpeditionMgr.RefreshMapFistWardInfo( logicMgr.ExpeditionMgr.mapId )
        self:ClickResetSure()
    else
        self.ctrlReset.selectedIndex = 0
    end
    self.privilegeController.selectedIndex = 0;
    local passNum = logicMgr.ExpeditionMgr.GetPassNum();
    if passNum > 0 then
        self.privilegeController.selectedIndex = 1;
        self.Text_Num1.text = "+"..(passNum * 0.01).."%";
        self.Text_Num2.text = string.format(getLanguage("NobleRightDesc3"), passNum * 0.01);
    end

    --设置扫荡按钮状态
    local maxSweepCount = G.dataTable["t_global"][tostring(383)]["f_string_value"]; --最大用券次数
    if logicMgr.FuncOpenManager.isOpen(Config.FuncOpenType.ExpeditionSweep,false) then
        --判断是否已经设置手动打
        if logicMgr.ExpeditionMgr.GetCanSweep() == 0 or logicMgr.ExpeditionMgr.GetSweepCount() == maxSweepCount then  --不能扫荡
            self.ctrlSweepType.selectedIndex = 2
        else    --可以扫荡
            self.ctrlSweepType.selectedIndex = 1
        end
    else
        self.ctrlSweepType.selectedIndex = 0
    end
end
function t:RefreshMapIcon()
    local cfg = dataTable.getDataTableById("t_expeditionchapter",logicMgr.ExpeditionMgr.mapId)
    self.mapIcon:GetChild("name").text = getLanguage(cfg.f_MapName)
    --self.mapIcon:GetController("star").selectedIndex = logicMgr.ExpeditionMgr.mapDifficulty-1
    self.mapIcon:GetChild("Mapicon").url = "ui://UILongJourney/"..cfg.f_MapIcon
    self.ctrlMap.selectedIndex = logicMgr.ExpeditionMgr.mapId - 1
    self.ctrlMap2.selectedIndex = logicMgr.ExpeditionMgr.mapId - 1
end
function t:RefreshReset()
    --[[local count = logicMgr.ExpeditionMgr.resetCount
    self.resetTitle.text = string.format(getLanguage("expedition_reset_button_tip"),count)
    if count == 0 then
        self.btnReset.grayed = true
    else
        self.btnReset.grayed = false
    end]]
end
function t:RefreshTicket()
    local ticketNum = logicMgr.ItemManager.getItemCountbyModelId(CurrencyEnum.ExpeditionTicket);
    local singleItemConfig = logicMgr.ItemManager.getItemConstDatabyModelId(CurrencyEnum.ExpeditionTicket);
    self.ticketIcon.icon = "ui://ItemAtlas/" .. singleItemConfig["icon"];
    self.ticketCount.text = tostring(ticketNum);
end
function t:GetLevelBtnByLevelId(id)
    return self.levelBtnList[id]
end
function t:UpdateTime()
    if logicMgr.ExpeditionMgr.endTime == 0 then
        self.resetTime.text = "00:00:00"
        return
    end
    local time = logicMgr.ExpeditionMgr.endTime-HelperFunc.GetServerTime()
    self.resetTime.text = string.format(getLanguage("expedition_reset_time_tip"),HelperFunc.GetTimeStr(time))
    if time <= 0 then
        logicMgr.ExpeditionMgr.RefreshTimeFinished()
        self:RefreshReset()
        self:UpdateTime()
        local flag = GetPlayerPrefsTodayFlag("expeditionResetTip")
        if not flag then
            self:ClickReset()
            SetPlayerPrefsTodayFlag("expeditionResetTip",true)
        end
    end
end
function t:RefreshPath(index,isShow)
    local ctrl = self.pathList[index]
    if not ctrl then return end
    ctrl.selectedIndex = isShow and 0 or 1
end
function t:RefreshLevelBtn()
    for k,v in pairs(self.levelBtnList) do
        self:RefreshLevelBtnById(k)
    end
end
function t:RefreshLevelBtnById(stageId)
    local v = self.levelBtnList[stageId]
    if not v then return end
    local StageState = logicMgr.ExpeditionMgr.StageState
    local cfg = logicMgr.ExpeditionMgr.GetCurStageCfg(stageId)
    local state = logicMgr.ExpeditionMgr.GetStageFullState(stageId)
    if cfg.f_Icon ~= "" then
        v.icon.url = cfg.f_Icon
    end
    if state == StageState.open then
        v.ctrlType.selectedIndex = cfg.f_ExpeditionType -1
    elseif state == StageState.reward then
        v.ctrlType.selectedIndex = 3
    elseif state == StageState.rewardOver then
        v.ctrlType.selectedIndex = 4
    elseif state == StageState.unlock then
        v.ctrlType.selectedIndex = cfg.f_ExpeditionType -1
    end
    self:RefreshPath(stageId-1,state ~= StageState.unlock)
    if state == StageState.open then
        v.ctrlHead.selectedIndex = 1
        local cfg = dataTable.getDataTableById("t_longjourneybubble",logicMgr.ExpeditionMgr.mapId)
        if cfg then
            local pos = decodeJsonStrToTabel(cfg["f_BubblePosition"..stageId])
            self.player.visible = true
            self.player:SetXY(v.go.x + pos[1],v.go.y + pos[2])
            self.player:GetController("fangxiang").selectedIndex = pos[3]
        end
    else
        v.ctrlHead.selectedIndex = 0
    end
end

function t:ClickLevelBtn(levelId)
    local state = logicMgr.ExpeditionMgr.GetStageFullState(levelId)
    local StageState = logicMgr.ExpeditionMgr.StageState
    if state == StageState.open then
        if levelId > 1 and logicMgr.ExpeditionMgr.GetStageFullState(levelId-1) == StageState.reward then
            UISysTips.AddMsg(getLanguage("expedition_need_get_award_tip"))
            return
        end
        logicMgr.UIShowManager.ShowExpeditionStagePreview(levelId)

    elseif state == StageState.reward then
        ExpeditionHandler.ReqGetAward(levelId)
   elseif state == StageState.unlock then
        UISysTips.AddMsg(getLanguage("expedition_need_pass_preStage_tip"))
    end
end
function t:ClickChallenge()
    if self.isWaitingMsg then
        logError("等待消息归来")
        return
    end
    if logicMgr.ExpeditionMgr.showBuffId[1] > 0 then
        logError("等待buff选择")
        return
    end
    local mgr = logicMgr.ExpeditionMgr
    local id = mgr.GetCurStageId()
    if id > 1 and mgr.GetStageFullState(id-1) == mgr.StageState.reward then
        UISysTips.AddMsg(getLanguage("expedition_need_get_award_tip"))
        return
    end
    if mgr.IsGetAllStageReward() then
        UISysTips.AddMsg(getLanguage("expedition_complete"))
        return
    end
    local formations = logicMgr.FormationManager.GetFormation(EnumConst.FormationType.Expedition)
    for k,v in pairs(formations) do
        local id = tostring(v)
        if logicMgr.ExpeditionMgr.IsDead(id) then
            formations[k] = "0"
        end
    end
    logicMgr.FormationManager.SetFormation(EnumConst.FormationType.Expedition,formations)
    showUI(PanelNames.UIBattleTeam, EnumConst.FightTypeConst.Expedition, id, function(formations,enemy)
        logicMgr.ExpeditionMgr.ClearHeroDeadFlag()
        ExpeditionHandler.ReqExpeditionBoss(id, formations[1]);
    end,function()
        logicMgr.ExpeditionMgr.ClearHeroDeadFlag()
    end);
    --logicMgr.UIShowManager.ShowExpeditionStagePreview(id)
end
function t:ClickSweep()
    --获取当前扫荡按钮状态
    local curSweepType = self.ctrlSweepType.selectedIndex;
    if curSweepType == 0 then   --vip等级不足
        UISysTips.AddMsg(string.format(getLanguage("expedition__mopp_up_des1"),G.dataTable["t_functionswitch"][tostring(614)].f_UnlockVipRank or 1));
        --elseif curSweepType == 1 then   --可扫荡
        --    ExpeditionHandler.ReqExpeditionSweep();
        --elseif curSweepType == 2 then   --已选择
        --    UISysTips.AddMsg("当前已选择或已完成");
    else
        ExpeditionHandler.ReqExpeditionSweep();
    end
end
function t:ClickGiveUp()
    local pop = CtrlManager.GetCtrl(PanelNames.UICommonPop);
    pop.Init("107", function(b)
        if b then
            self:ClickResetSure()
        end
    end)
end
function t:ShowAddStrength()
    local itemId = logicMgr.ItemManager.getItemIdByModelId(200035)
    if itemId then
        local itemData = logicMgr.ItemManager.getItemData(itemId)
        showUI(PanelNames.UIBagItemInfo, itemData, 1,nil, true);
    else
        UISysTips.AddMsg(getLanguage("ErrorCode_220002"))
    end
end
function t:ClickClose()
    if ExpeditionMapMgr.isLoading then
        logError("正在加载地图，请稍后")
        return
    end
    closeUI(PanelNames.UIExpeditionStageView)

    showUI(PanelNames.UIBottom,true)
    UIBottom.enterAdventure()
end
function t:ClickReset()
    if logicMgr.ExpeditionMgr.resetCount == 0 then
        return
    end
    if logicMgr.ExpeditionMgr.IsGetAllStageReward() then
        self:ClickResetSure()
        if isOpenUI(PanelResNames.UIExpeditionSelectBuff) then
            closeUI(PanelNames.UIExpeditionSelectBuff)
        end
    else
        logicMgr.UIShowManager.ShowCommonConfirm(getLanguage("expedition_reset_confirm_tip"),nil,function()
            self:ClickResetSure()
            if isOpenUI(PanelResNames.UIExpeditionSelectBuff) then
                closeUI(PanelNames.UIExpeditionSelectBuff)
            end
        end)
    end
end
function t:ClickUseTicket()
    local ticketCount = logicMgr.ItemManager.getItemCountbyModelId(CurrencyEnum.ExpeditionTicket);
    if ticketCount > 0 then
        if logicMgr.ExpeditionMgr.IsCompleteAllStage() then
            logicMgr.ExpeditionMgr.SetClickSweep(true)
        end
        FireEvent(Config.EventType.ExpeditionSweepRefresh)
        local curSweepCount = logicMgr.ExpeditionMgr.GetSweepCount()
        local maxSweepCount = tonumber(G.dataTable["t_global"][tostring(383)]["f_string_value"])
        if curSweepCount < maxSweepCount then
            logicMgr.UIShowManager.ShowCommonConfirm(string.format(getLanguage("expedition__mopp_up_des4"),curSweepCount,maxSweepCount),nil,function()
                self:ClickResetSure()
                logicMgr.ExpeditionMgr.SetClickSweep(false)
            end,nil,nil,nil,nil,nil,CurrencyEnum.ExpeditionTicket)
        else
            UISysTips.AddMsg(getLanguage("expedition__mopp_up_des7"))  --使用次数达到上限
        end
    else
        UISysTips.AddMsg(getLanguage("expedition__mopp_up_des6"))
    end
end
function t:ClickResetSure()
    ExpeditionHandler.ReqResetExpedition()
    --closeUI(PanelNames.UIExpeditionStageView)
    --showUI(PanelNames.UIExpeditionMapView)
end

function t:ClickResetCancel()
    --closeUI(PanelNames.UIExpeditionStageView)
    --showUI(PanelNames.UIExpeditionStageView)
end
function t:ClickInfo()
    logicMgr.UIShowManager.ShowCommonTips("expedition_info_title","expedition_info_des","FunctionStory304")
end
--女神祝福
function t:ClickBless()
    logicMgr.UIShowManager.ShowExpeditionCarPreview()
end
--神圣结晶
function t:ClickHolyStone()
    logicMgr.UIShowManager.ShowExpeditionHolyStone(nil,function ()
        self:ClickClose();
    end)
end
--英雄
function t:ClickHero()
    logicMgr.UIShowManager.ShowExpeditionHeroList()
end
--远征商店
function t:ClickShop()
    logicMgr.UIShowManager.ShowUIShop(EnumConst.ShopType.expeditionShop,nil,4)
end
function t:ShowSelectBuffView()
    local id = logicMgr.ExpeditionMgr.GetCurStageId()
    local stageId = id - 1
    logicMgr.UIShowManager.ShowExpeditionSelectBuffView(stageId,logicMgr.ExpeditionMgr.showBuffId)
end
function t:ExpeditionDataRefreshMsg()
    self.isWaitingMsg = false
    self:RemoveTimeCall(self.ReqSynExpedition)
    self.delayLoad = false
    ExpeditionMapMgr.LoadScene()
    self:Refresh()
    --弹完成远征
    if ExpeditionMgr.needShowLastTip and ExpeditionMgr.IsCompleteAllStage() then
        ExpeditionMgr.needShowLastTip = false
        local info = ExpeditionMgr.GetStageInfo(ExpeditionMgr.GetCurStageId())
        logicMgr.UIShowManager.ShowExpeditionFinalBossReward(info.items)
    end
    if logicMgr.ExpeditionMgr.showBuffId[1] > 0 then
        self:ShowSelectBuffView()
    end
end
function t:ExpeditionStartLoadingMsg(isStart)
    self.ctrlMarkLoading.selectedIndex = isStart and 1 or 0
end
function t:SelectBuffOver()
    --log("over")
end
--[[function t:ExpeditionGetRewardSucMsg(stageId)
    local cfg = logicMgr.ExpeditionMgr.GetCurStageCfg(stageId)
    if cfg then
        if cfg.f_ExpeditionType == 3 then
            local info = logicMgr.ExpeditionMgr.GetStageInfo(stageId)
            logicMgr.UIShowManager.ShowExpeditionFinalBossReward(info.items,self.ShowFinalBossFinished,self)
        else
            local info = logicMgr.ExpeditionMgr.GetStageInfo(stageId)
            logicMgr.UIShowManager.ShowReward(info.items,function()
                if logicMgr.ExpeditionMgr.showBuffId > 0 then
                    self:ShowSelectBuffView()
                end
            end)
        end
        self:RefreshLevelBtnById(stageId)
        self:RefreshLevelBtnById(stageId+1)
    else
        logError("expedition 找不到关卡:"..stageId)
    end

end
function t:ShowFinalBossFinished()
    if logicMgr.ExpeditionMgr.IsCompleteAllStage() then
        self.ctrlReset.selectedIndex = 1
        self.player.visible = false
    else
        self.ctrlReset.selectedIndex = 0
    end
    self:ClickReset()
end]]
return t